﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



namespace QuizSilverlight.Web.Administration
{
    public partial class AddQuestions : System.Web.UI.Page
    {
        QuizDataClassesDataContext quizzDC = new QuizDataClassesDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            Console.WriteLine();
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            Question question = new Question();
            Answer answer1 = new Answer();
            Answer answer2 = new Answer();
            Answer answer3 = new Answer();

            ////ajouter les réponses
            answer1.Body = tb_Answer1.Text;
            answer1.IsValid = cb1.Checked;


            answer2.Body = tb_Answer2.Text;
            answer2.IsValid = cb2.Checked;


            answer3.Body = tb_Answer3.Text;
            answer3.IsValid = cb3.Checked;


            //ajouter question
            question.Body = tb_Question.Text;
            question.Id_WebSite = 1;// à changer selon le site
            question.Answer.Add(answer1);
            question.Answer.Add(answer2);
            question.Answer.Add(answer3);// automatiquement il ajoute les answers avec l'id de la question dans la table

            quizzDC.Question.InsertOnSubmit(question);

            quizzDC.SubmitChanges();

           
        }




    }
}